package role

import (
	//"fmt"
	"github.com/astaxie/beego/orm"
	//"gitee.com/yesy/mdzs.git/g"
	. "gitee.com/yesy/mdzs.git/models"
)

func OneByIdInDB(rolename string) *Role {
	if rolename == "" {
		return nil
	}

	o := Role{RoleName: rolename}
	err := orm.NewOrm().Read(&o, "RoleName")
	if err != nil {
		return nil
	}
	return &o
}

func Save(this *Role) (int64, error) {
	
	num, err := orm.NewOrm().Insert(this)
	
	return num, err
}

func Del(c *Role) error {
	//num, err := orm.NewOrm().Delete(c)
	//if err != nil {
	//	return err
	//}

	return nil
}

func Update(this *Role) error {
	
	return nil
}

func Roles() orm.QuerySeter {
	return orm.NewOrm().QueryTable(new(Role))
}
